import Vue from 'vue'
import Element from 'element-ui'
import 'element-ui/lib/theme-chalk/index.css'

let count = 0
let ld = null

const start = () => {
  if (count === 0) {
    ld = Element.Loading.service({
      lock: true,
      text: 'Loading',
      spinner: 'el-icon-loading',
      background: 'rgba(0, 0, 0, 0.3)'
    })
  }
  count++
}

const stop = () => {
  if (count <= 0) {
    return
  }
  count--
  if (count === 0) {
    ld.close()
  }
}
Vue.prototype.$start = start
Vue.prototype.$stop = stop
Vue.use(Element)

const icons = [
  'el-icon-s-platform', 'el-icon-user-solid', 'el-icon-user', 'el-icon-unlock', 'el-icon-notebook-2', 'el-icon-school',
  'el-icon-check', 'el-icon-video-play', 'el-icon-s-tools', 'el-icon-setting', 'el-icon-message-solid', 'el-icon-bell',
  'el-icon-mobile-phone', 'el-icon-map-location', 'el-icon-location', 'el-icon-document', 'el-icon-s-check', 'el-icon-data-analysis',
  'el-icon-view', 'el-icon-s-home', 'el-icon-office-building', 'el-icon-picture', 'el-icon-odometer', 'el-icon-s-data',
  'el-icon-tickets', 'el-icon-delete-solid', 'el-icon-phone-outline', 'el-icon-phone', 'el-icon-star-on', 'el-icon-star-off',
  'el-icon-warning', 'el-icon-upload', 'el-icon-download', 'el-icon-s-custom', 'el-icon-house', 'el-icon-message', 'el-icon-thumb',
  'el-icon-search', 'el-icon-collection', 'el-icon-s-promotion', 'el-icon-refresh'
]

export default {
  start,
  stop,
  icons
}
